package com.itlong.cloud.controller.workWechat;

import com.itlong.cloud.POJO.DTO.foreign.WorkWechatSendData;
import com.itlong.cloud.annotation.UnAuthAccessRequired;
import com.itlong.cloud.service.WorkWechat;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 企业微信告警接口
 * zhouchun
 * 2021-04-29
 */
@RestController
@RequestMapping(path = "/workWechat")
public class WarnController {

    @Autowired
    WorkWechat workWechat;

    @UnAuthAccessRequired
    @RequestMapping("sendText")
    public String sendText(@RequestBody WorkWechatSendData r) {
        String channel = r.getChannel();
        String content = r.getContent();
        if (channel == null || !channel.equals("itlong")) {
            return "illegal request";
        }
        return workWechat.sendText(content);
    }

}